package com.pactera.madp.cp.context;

import com.pactera.madp.cp.handler.sync.SyncTypeHandler;

import java.util.Map;

public class HandlerContext {
    private Map<String, SyncTypeHandler> handlerMap;

    public HandlerContext(Map<String, SyncTypeHandler> handlerMap){
        this.handlerMap = handlerMap;
    }

    // 获取实例
    public SyncTypeHandler getInstance(String type){
        if(type == null){
            throw new IllegalArgumentException("参数不能为空");
        }
        SyncTypeHandler clazz = handlerMap.get(type);
        if(clazz == null){
            throw new IllegalArgumentException("该类型未在枚举中定义");
        }
        return clazz;
    }

}
